/*   1:    */ package org.jetbrains.lang.manifest.parser;
/*   2:    */ 
/*   3:    */

import com.intellij.lexer.LexerBase;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.lang.manifest.psi.ManifestTokenType;

import java.util.HashMap;
import java.util.Map;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */ 
/*  12:    */ public class ManifestLexer
/*  13:    */   extends LexerBase
/*  14:    */ {
/*  15: 47 */   private static final Map<Character, IElementType> a = new HashMap();
/*  16:    */   private CharSequence b;
/*  17:    */   private int c;
/*  18:    */   private int d;
/*  19:    */   private int e;
/*  20:    */   private State f;
/*  21:    */   private IElementType g;
/*  22:    */   
/*  23:    */   static
/*  24:    */   {
/*  25: 48 */     a.put(Character.valueOf(':'), ManifestTokenType.COLON);
/*  26: 49 */     a.put(Character.valueOf(';'), ManifestTokenType.SEMICOLON);
/*  27: 50 */     a.put(Character.valueOf(','), ManifestTokenType.COMMA);
/*  28: 51 */     a.put(Character.valueOf('='), ManifestTokenType.EQUALS);
/*  29: 52 */     a.put(Character.valueOf('('), ManifestTokenType.OPENING_PARENTHESIS_TOKEN);
/*  30: 53 */     a.put(Character.valueOf(')'), ManifestTokenType.CLOSING_PARENTHESIS_TOKEN);
/*  31: 54 */     a.put(Character.valueOf('['), ManifestTokenType.OPENING_BRACKET_TOKEN);
/*  32: 55 */     a.put(Character.valueOf(']'), ManifestTokenType.CLOSING_BRACKET_TOKEN);
/*  33: 56 */     a.put(Character.valueOf('"'), ManifestTokenType.QUOTE);
/*  34:    */   }
/*  35:    */   
/*  36:    */   public void start(@NotNull CharSequence paramCharSequence, int paramInt1, int paramInt2, int paramInt3)
/*  37:    */   {
/*  38: 68 */     if (paramCharSequence == null) {
/*  39: 68 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/lang/manifest/parser/ManifestLexer", "start" }));
/*  40:    */     }
/*  41: 68 */     this.b = paramCharSequence;
/*  42: 69 */     this.c = paramInt2;
/*  43: 70 */     this.f = State.values()[paramInt3];
/*  44:    */     
/*  45: 72 */     this.d = paramInt1;
/*  46: 73 */     a();
/*  47:    */   }
/*  48:    */   
/*  49:    */   public void advance()
/*  50:    */   {
/*  51: 78 */     this.d = this.e;
/*  52: 79 */     a();
/*  53:    */   }
/*  54:    */   
/*  55:    */   public int getState()
/*  56:    */   {
/*  57: 84 */     return this.f.ordinal();
/*  58:    */   }
/*  59:    */   
/*  60:    */   @Nullable
/*  61:    */   public IElementType getTokenType()
/*  62:    */   {
/*  63: 90 */     return this.g;
/*  64:    */   }
/*  65:    */   
/*  66:    */   public int getTokenStart()
/*  67:    */   {
/*  68: 95 */     return this.d;
/*  69:    */   }
/*  70:    */   
/*  71:    */   public int getTokenEnd()
/*  72:    */   {
/*  73:100 */     return this.e;
/*  74:    */   }
/*  75:    */   
/*  76:    */   public int getBufferEnd()
/*  77:    */   {
/*  78:105 */     return this.c;
/*  79:    */   }
/*  80:    */   
/*  81:    */   @NotNull
/*  82:    */   public CharSequence getBufferSequence()
/*  83:    */   {
/*  84:111 */     CharSequence tmp4_1 = this.b;
/*  85:111 */     if (tmp4_1 == null) {
/*  86:111 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/lang/manifest/parser/ManifestLexer", "getBufferSequence" }));
/*  87:    */     }
/*  88:111 */     return tmp4_1;
/*  89:    */   }
/*  90:    */   
/*  91:    */   private void a()
/*  92:    */   {
/*  93:115 */     if (this.d < this.c)
/*  94:    */     {
/*  95:116 */       if (a(this.d))
/*  96:    */       {
/*  97:117 */         this.g = (f(this.d) ? ManifestTokenType.SECTION_END : ManifestTokenType.NEWLINE);
/*  98:118 */         this.e = (this.d + 1);
/*  99:119 */         this.f = State.INITIAL_STATE;
/* 100:    */       }
/* 101:121 */       else if (this.f == State.WAITING_FOR_HEADER_ASSIGNMENT_STATE)
/* 102:    */       {
/* 103:122 */         if (h(this.d))
/* 104:    */         {
/* 105:123 */           this.g = ManifestTokenType.COLON;
/* 106:124 */           this.f = State.WAITING_FOR_SPACE_AFTER_HEADER_NAME_STATE;
/* 107:    */         }
/* 108:    */         else
/* 109:    */         {
/* 110:127 */           this.g = TokenType.BAD_CHARACTER;
/* 111:    */         }
/* 112:129 */         this.e = (this.d + 1);
/* 113:    */       }
/* 114:131 */       else if (this.f == State.WAITING_FOR_SPACE_AFTER_HEADER_NAME_STATE)
/* 115:    */       {
/* 116:132 */         if (g(this.d))
/* 117:    */         {
/* 118:133 */           this.e = (this.d + 1);
/* 119:134 */           this.g = ManifestTokenType.SIGNIFICANT_SPACE;
/* 120:    */         }
/* 121:    */         else
/* 122:    */         {
/* 123:137 */           this.e = this.d;
/* 124:138 */           while ((this.e < this.c) && (!i(this.e)) && (!a(this.e))) {
/* 125:139 */             this.e += 1;
/* 126:    */           }
/* 127:141 */           this.g = ManifestTokenType.HEADER_VALUE_PART;
/* 128:    */         }
/* 129:143 */         this.f = State.INITIAL_STATE;
/* 130:    */       }
/* 131:145 */       else if (b(this.d))
/* 132:    */       {
/* 133:146 */         if (c(this.d))
/* 134:    */         {
/* 135:147 */           this.e = (this.d + 1);
/* 136:148 */           while ((this.e < this.c) && (d(this.e))) {
/* 137:149 */             this.e += 1;
/* 138:    */           }
/* 139:151 */           this.g = ManifestTokenType.HEADER_NAME;
/* 140:152 */           this.f = State.WAITING_FOR_HEADER_ASSIGNMENT_STATE;
/* 141:    */         }
/* 142:    */         else
/* 143:    */         {
/* 144:155 */           this.e = (this.d + 1);
/* 145:156 */           this.g = TokenType.BAD_CHARACTER;
/* 146:157 */           this.f = State.BROKEN_LINE;
/* 147:    */         }
/* 148:    */       }
/* 149:160 */       else if (e(this.d))
/* 150:    */       {
/* 151:161 */         this.g = ManifestTokenType.SIGNIFICANT_SPACE;
/* 152:162 */         this.e = (this.d + 1);
/* 153:163 */         this.f = State.INITIAL_STATE;
/* 154:    */       }
/* 155:165 */       else if (this.f == State.BROKEN_LINE)
/* 156:    */       {
/* 157:166 */         this.e = (this.d + 1);
/* 158:167 */         this.g = TokenType.BAD_CHARACTER;
/* 159:    */       }
/* 160:169 */       else if (i(this.d))
/* 161:    */       {
/* 162:170 */         this.g = j(this.d);
/* 163:171 */         this.e = (this.d + 1);
/* 164:172 */         this.f = State.INITIAL_STATE;
/* 165:    */       }
/* 166:    */       else
/* 167:    */       {
/* 168:175 */         this.e = this.d;
/* 169:176 */         while ((this.e < this.c) && (!i(this.e)) && (!a(this.e))) {
/* 170:177 */           this.e += 1;
/* 171:    */         }
/* 172:179 */         this.g = ManifestTokenType.HEADER_VALUE_PART;
/* 173:    */       }
/* 174:    */     }
/* 175:    */     else
/* 176:    */     {
/* 177:183 */       this.g = null;
/* 178:184 */       this.e = this.d;
/* 179:    */     }
/* 180:    */   }
/* 181:    */   
/* 182:    */   private boolean a(int paramInt)
/* 183:    */   {
/* 184:189 */     return this.b.charAt(paramInt) == '\n';
/* 185:    */   }
/* 186:    */   
/* 187:    */   private boolean b(int paramInt)
/* 188:    */   {
/* 189:193 */     return (f(paramInt)) && (!Character.isWhitespace(this.b.charAt(paramInt)));
/* 190:    */   }
/* 191:    */   
/* 192:    */   private boolean c(int paramInt)
/* 193:    */   {
/* 194:197 */     return Character.isLetterOrDigit(this.b.charAt(paramInt));
/* 195:    */   }
/* 196:    */   
/* 197:    */   private boolean d(int paramInt)
/* 198:    */   {
/* 199:201 */     return (c(paramInt)) || (this.b.charAt(paramInt) == '-') || (this.b.charAt(paramInt) == '_');
/* 200:    */   }
/* 201:    */   
/* 202:    */   private boolean e(int paramInt)
/* 203:    */   {
/* 204:205 */     return (f(paramInt)) && (!b(paramInt));
/* 205:    */   }
/* 206:    */   
/* 207:    */   private boolean f(int paramInt)
/* 208:    */   {
/* 209:209 */     return (paramInt == 0) || (a(paramInt - 1));
/* 210:    */   }
/* 211:    */   
/* 212:    */   private boolean g(int paramInt)
/* 213:    */   {
/* 214:213 */     return this.b.charAt(paramInt) == ' ';
/* 215:    */   }
/* 216:    */   
/* 217:    */   private boolean h(int paramInt)
/* 218:    */   {
/* 219:217 */     return this.b.charAt(paramInt) == ':';
/* 220:    */   }
/* 221:    */   
/* 222:    */   private boolean i(int paramInt)
/* 223:    */   {
/* 224:221 */     return a.get(Character.valueOf(this.b.charAt(paramInt))) != null;
/* 225:    */   }
/* 226:    */   
/* 227:    */   private IElementType j(int paramInt)
/* 228:    */   {
/* 229:225 */     return (IElementType)a.get(Character.valueOf(this.b.charAt(paramInt)));
/* 230:    */   }
/* 231:    */   
/* 232:    */   private static enum State
/* 233:    */   {
/* 234:    */     private State() {}
/* 235:    */   }
/* 236:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.lang.manifest.parser.ManifestLexer

 * JD-Core Version:    0.7.0.1

 */